package com.lan.script;

import com.lan.model.Type;
import com.lan.model.symbol.Scope;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public abstract class ScriptObject {

    protected Map<Object, Object> metadata = Collections.emptyMap();

    public Map<Object, Object> getMetadata() {
        return this.metadata;
    }

    public ScriptObject withMeta(final Object key, final Object value) {
        if (this.metadata.isEmpty()) {
            this.metadata = new HashMap<Object, Object>();
        }
        this.metadata.put(key, value);
        return this;
    }

    public Object meta(final Object key) {
        return this.metadata.get(key);
    }

    public ScriptObject withoutMeta(final Object key) {
        this.metadata.remove(key);
        return this;
    }

    public abstract Type getType();

    public abstract Scope getScope();

    public abstract Object getValue();


}
